/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
document.write("<script language='javascript' src='http://api.go2map.com/maps/js/api_v2.5.1.js'></" + "script>");
function createMarker(jsonList, jsonListSheng) {
    var myLatlng = new sogou.maps.Point(11799000, 3842375);
    var myOptions = {
        zoom: 4,
        center: myLatlng,
        mapTypeId: sogou.maps.MapTypeId.ROADMAP
    }

    var map = new sogou.maps.Map(document.getElementById("map_canvas"), myOptions);

//                var jsonList = #{regionCodeController.points()};
//                var jsonListSheng = #{regionCodeController.pointsSheng()};
    for (var i = 0; !(i >= jsonListSheng.length); i++) {
        var marker = eval(i + "");
        var marker = new sogou.maps.Marker({
            position: new sogou.maps.Point(jsonListSheng[i]["pointx"], jsonListSheng[i]["pointy"]),
            map: map,
            title: jsonListSheng[i]["point"] + ",x=" + jsonListSheng[i]["pointx"] + ",y=" + jsonListSheng[i]["pointy"],
            id: jsonListSheng[i]["point"]
        });
        attachSecretMessage(marker)
    }
//    sogou.maps.event.addListener(map, 'click', function(event) {
//            alert(event.point);
//            window.location.href = "http://localhost:8080//Map/faces/index.xhtml?quyuID=" + marker.id;
//        });


    //添加侦听器，当缩放地图时触发，弹出对话框
    sogou.maps.event.addListener(map, 'zoom_changed', function() {
        if (!(map.getZoom() > 5)) {
            reSetMarker(jsonListSheng);
        } else if (map.getZoom() > 5) {
            reSetMarker(jsonList);
        }

    });

}

function reSetMarker(points) {
    map.clearAll();
    for (var i = 0; !(i >= points.length); i++) {
        var marker = new sogou.maps.Marker({
            position: new sogou.maps.Point(points[i]["pointx"], points[i]["pointy"]),
            title: points[i]["point"] + ",x=" + points[i]["pointx"] + ",y=" + points[i]["pointy"],
            map: map
        });
        attachSecretMessage(marker);
    }
}
function attachSecretMessage(marker) {
    var url = "http://localhost:8080//Map/faces/index.xhtml?quyuID=" + marker.id;
    sogou.maps.event.addListener(marker, 'click', function() {
        window.location.href = url;
    });
}